<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js" type="application/javascript"></script>
    <title>新闻网</title>
</head>
<body>
    <div id="time">时间：</div>
    <button onclick="refresh()">刷新</button>
    <ul id="news">
    </ul>
    <script>
        function time() {
            $('#time').html(new Date());
        }
        time();
        function refresh() {
            $('#news').html('');
            $.ajax("http://localhost/api.php",{
                dataType: 'json',
                success: function(data) {
                    $.each(data, function(i,d){
                        $('#news').append(`<li>${d.title} ${d.create_time}</li>`)
                    });
                }
            })
        }
        refresh();
    </script>
</body>
</html>